package castledefense.game.render;

import castledefense.data.GameData;
import castledefense.game.render.effects.UnitDeath;

import com.badlogic.gdx.graphics.g2d.SpriteBatch;

public class RenderUnitDeaths {

	final private UnitDeath fireDeathHandler = new UnitDeath(GameData.fire);
	final private UnitDeath waterDeathHandler = new UnitDeath(GameData.water);
	final private UnitDeath earthDeathHandler = new UnitDeath(GameData.earth);
	final private UnitDeath airDeathHandler = new UnitDeath(GameData.air);

	public RenderUnitDeaths() {

	}

	public void dispose() {
		fireDeathHandler.dispose();
		waterDeathHandler.dispose();
		earthDeathHandler.dispose();
		airDeathHandler.dispose();

	}

	public void render(SpriteBatch spriteBatch, float delta) {
		fireDeathHandler.render(spriteBatch, delta);
		waterDeathHandler.render(spriteBatch, delta);
		earthDeathHandler.render(spriteBatch, delta);
		airDeathHandler.render(spriteBatch, delta);
	}

	public void update(int delta) {
		fireDeathHandler.update(delta);
		waterDeathHandler.update(delta);
		earthDeathHandler.update(delta);
		airDeathHandler.update(delta);
	}

	public void addDeath(int type, float x, float y) {
		if (type == GameData.fire) {
			fireDeathHandler.addBlast(x, y);
		} else if (type == GameData.water) {
			waterDeathHandler.addBlast(x, y);
		} else if (type == GameData.earth) {
			earthDeathHandler.addBlast(x, y);
		} else if (type == GameData.air) {
			airDeathHandler.addBlast(x, y);
		}
	}

}
